package pl.streamsoft.currencyApp.stream;

import java.io.InputStream;
import java.net.URL;

public class UrlStream implements IStream{

	final private String url;
	private InputStream is;
	
	public UrlStream(String url){
		this.url = url;
	}
	
	@Override
	public InputStream getInputStream() {
		return is == null ? openStream() : is;
	}

	private InputStream openStream() {
		try{
			is = new URL(url).openStream();
			return is;
		} catch(Exception e){
			return null;
		}
	}

}
